package com.yangc.stream.rabbit.controller;

import com.yangc.stream.rabbit.producer.DemoProducer;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DemoController {

    private final DemoProducer producer;

    public DemoController(DemoProducer producer) {
        this.producer = producer;
    }

    @GetMapping("/send")
    public String send(String msg) {
        producer.sendMessage(msg);
        return "已发送: " + msg;
    }

    @GetMapping("/sendDelay")
    public String sendDelay(String msg, int delayMs) {
        producer.sendDelayMessage(msg, delayMs);
        return "已发送延迟消息: " + msg + " delay=" + delayMs + "ms";
    }
}
